package org.hackystat.devcathlon.ui.page.commons.panels.match;

import java.util.List;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.hackystat.devcathlon.engine.match.Match;
import org.hackystat.devcathlon.engine.match.MatchManager;

/**
 * Match cards panel.
 * @author Anthony Du
 *
 */
public class MatchCardsPanel extends Panel {
  /** Support Serialization. */
  private static final long serialVersionUID = 1L;
  
  /**
   * Match cards panel constructor.
   * @param id The match cards id.
   * @param matchNames The list of match names.
   */
  public MatchCardsPanel(String id, List<String> matchNames) {
    super(id);
    WebMarkupContainer leftMatchesColumn = new WebMarkupContainer("matchesLeft");
//    WebMarkupContainer rightMatchesColumn = new WebMarkupContainer("matchesRight");
    leftMatchesColumn.add(new ListView("matches", matchNames) {
      /** Support Serialization. */
      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(final ListItem item) {
        final String matchName = (String) item.getModelObject();
        final Match match = MatchManager.getInstance().getMatch(matchName);
        item.add(new MatchCardPanel("matchCardPanel", match));
      }
    });
    add(leftMatchesColumn);
  }
}
